<template>
  <div>
      <div id="slider" class="mui-slider">
        <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
            <div class="mui-scroll">
                <a :class="['mui-control-item',item.id===0 ?'mui-active' :'']" href="javascript:;" 
                data-wid="tab-top-subpage-1.html" v-for="item in msg" :key="item.id" @click="getPhoto(item.id)">
                    {{item.title}}
                </a>
            </div>
        </div>
    </div>
    <ul class="photoList">
    <router-link v-for="item in list" :key="item.id" tag="li" :to="'/home/pics/picinfo/'+item.id" >
      <img v-lazy="item.img_url">
      <div>
        <h1>{{item.title}}</h1>
        <span v-html="item.zhaiyao"></span>
      </div>
    </router-link>
  </ul>
  </div>
</template>
<script>
import mui from '../../assets/mui/js/mui.min.js'

export default {
    data(){
        return {
            msg:[],
            list:[]
        }
    },
    created(){
        this.getTop()
        this.getPhoto(0)
    },
    mounted(){
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        });
    },
    methods:{
        getTop(){
            this.$http.get('api/getimgcategory').then((results)=>{
                if(results.body.status===0){
                    this.msg=results.body.message;
                    this.msg.unshift({'title':'全部',id:0})
                }
            })
        },
        getPhoto(id){
            this.$http.get('api/getimages/'+id).then((results)=>{
                if(results.body.status===0){
                    this.list = results.body.message;
                    console.log(this.list)
                }
            })
        }
    },

};
</script>
<style lang="scss" scoped>
    *{
        touch-action:pan-y;
    }
    
    .mui-slider{
        border-bottom: 2px solid #ccc;
    }
    .photoList{
        background-color: #fff;
        padding: 10px;
        margin: 0;
        li{
            width: 100%;
            list-style: none;
            margin-bottom: 10px;
            box-shadow: 0px 0px 10px #000;
            background-color: #ccc;
            text-align: center;
            position: relative;
            img{
                width: 100%;
                vertical-align:hidden;
                
            }
            img[lazy="loading"] {
                width: 15%;
                height: 300px;
                margin: auto;
                
            }
            div{
                position: absolute;
                background-color: rgba(0, 0, 0, 0.7);
                bottom: 0;
                left: 0;
                text-align: left;
                color: #fff;
                h1{
                    font-size: 14px;

                }
                span{
                    width: 100%;
                    font-size: 12px;
                    display: block;
                    height: 65px;
                    display: -webkit-box;
                    -webkit-line-clamp: 3;
                    -webkit-box-orient: vertical;
                    overflow: hidden;
                }
            }
        }
    }
    
</style>

